#
# WMAC = WhoreMaster: Abby's Crossing
#

import sys
from PyQt4.QtGui import QApplication, QMainWindow, QLabel, QPixmap, QFontDatabase
from lib.data.game_data import data
from lib.screens.load_screen import LoadFileScreen
from lib.screens.main_menu import MainMenu
from lib.screens.main_screen import MainScreen
from lib.screens.new_game import NewGameScreen
from lib.screens.town_screen import TownScreen
from lib.screens.tart_management import TartManagement
from lib.screens.slave_market_screen import SlaveMarketScreen
from lib.screens.msg_box import MsgBox
from lib.screens import screen_manager
import lib.data.save_manager 

class Game(QApplication):
	instance = None

	def __init__(self, *args, **kw):
#
#		start by initialising the base class
#
		QApplication.__init__(self, *args, **kw)
#
#		QMainWindow gives us a window in which to display the game
#		We don't really need the Qt dock areas and menus, so
#		we could probably use a plain QWidget here.
#
#		On the other hand, it ain't broke, so ...
#
		self.window = QMainWindow()
		self.window.setGeometry(0, 0, 1024, 768)
		self.window.setWindowTitle("Abby's Crossing")
#
#		we add the mahogany background at this level.
#		it's just a QLabel
#
		pic = QLabel(self.window)
		pic.setGeometry(0, 0, 1024, 768)
		path = "resources/wood.jpg"
		pic.setPixmap(QPixmap(path))
#
#		add any fonts we need to the database
#		mainly I'm using "Gabrielle" by Dieter Steffmann,
#		to whom many thanks: http://www.dafont.com/gabrielle.font
#
		self.font_db = QFontDatabase()
		self.font_db.addApplicationFont("resources/Gabrielle.ttf")
		self.font_db.addApplicationFont("resources/mark.ttf")
#
#		each game screen has its own class and widget.
#		They all live in the "screens" dictionary
#		so I can look them up by keyword.
#		(setting the object name should have the same effect)
#
		screen_manager.add("main menu",  MainMenu(self.window))
		screen_manager.add("new game",  NewGameScreen(self.window))
		screen_manager.add("main screen",  MainScreen(self.window))
		screen_manager.add("town screen",  TownScreen(self.window))
		screen_manager.add("tarts screen",  TartManagement(self.window))
		screen_manager.add(
			"slave market screen",
			SlaveMarketScreen(self.window)
		)
		screen_manager.add("load screen", LoadFileScreen(self.window)) 
		screen_manager.add("message box", MsgBox(self.window)) 
#
#		Keep track of the current screen. Each screen starts out hidden 
#		so I can change screens by hiding the current one
#		and showing the new screen
#
		screen_manager.current = "main menu"
		screen_manager.show_current()

	def go(self):
		self.window.show()
		sys.exit(self.exec_())

if __name__ == "__main__":
	app = Game(sys.argv)
	app.go()


